
package com.lzb.browser.dialog;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.lxj.xpopup.core.AttachPopupView;
import com.lzb.browser.R;

public class EditDialog extends AttachPopupView implements View.OnClickListener {

    private TextView tvAdd;
    private TextView tvManage;

    public EditDialog(@NonNull Context context) {
        super(context);
    }

    @Override
    protected int getImplLayoutId() {
        return R.layout.dialog_edit;
    }

    @Override
    protected void onCreate() {
        super.onCreate();
        initView();
    }

    protected void initView() {
        tvAdd = findViewById(R.id.tvAdd);
        tvManage = findViewById(R.id.tvManage);

        tvAdd.setOnClickListener(this);
        tvManage.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        int id = v.getId();
        if (id == R.id.tvAdd) {
            dismiss();
            if (listener != null) {
                listener.clickAdd();
            }
        } else if (id == R.id.tvManage) {
            dismiss();
            if (listener != null) {
                listener.clickManage();
            }
        }
    }

    private Ilistener listener;

    public void setListener(Ilistener listener) {
        this.listener = listener;
    }

    public interface Ilistener {
        void clickAdd();

        void clickManage();
    }

}
